import  time

from selenium import webdriver
from selenium.webdriver import ActionChains
from selenium.webdriver.common.by import By


driver = webdriver.Chrome(executable_path='Chromedriver.exe')
# 2.输入访问地址（URL）
driver.get("http://121.43.169.97:8848/pageA.html")

#输入访问地址url
url = r"C:\Users\Admin\PycharmProjects\UI自动化测试\drop.html"
driver.get(url)

#实例化并获取ActionChains
action = ActionChains(driver)

#获取 源元素
surce = driver.find_element_by_css_selector("#div1")

#获取 目标元素
target = driver.find_element_by_css_selector("#div2")

time.sleep(3)
action.drag_and_drop(surce,target).perform()

#扩展，通过坐标偏移量执行
time.sleep(3)
action.drag_and_drop_by_offset(surce,xoffset=300,yoffset=300).perform()